home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / WINTOOLS.LIB < prev    next >
Text File  |  1993-12-10  |  20KB  |  538 lines

  1. // WinTools.lib - Functions for setting the state of of PM windows.  This
  2. //                file may be #included into other Cmm source files, or
  3. //                you can cut and paste in the parts that you need.
  4. //
  5. //                Note: Most of these routines require either a window
  6. //                handle or a window title.  You can use either, but
  7. //                using a Window handle is a little quicker.  Many of these
  8. //                utilities require that you include PMdll.lib.
  9. //
  10. //
  11. //***** GetWindowHandle(): Get the handle for this window
  12. // SYNTAX: int GetWindowHandle(int WindowHandle)
  13. //         int GetWindowHandle(string WindowTitle)
  14. // WHERE: WindowHandle: Integer identifier for this window
  15. //        WindowTitle: Partial text title of the window (case-insensitive)
  16. // RETURN: Returns Window handle for a Windows whose partial title is
  17. //         WindowTitle. Comparison is case-insensitive.  If WindowTitle
  18. //         is not found then returns 0 (NULL).
  19. // NOTE: If WindowHandle is input, then this returns WindowHandle if
  20. //       WindowHandle is valid, else returns 0.  WindowTitle is a partial
  21. //       and case-insensitive match and so "write" would match the
  22. //       window titled "Write - THESIS.WRI".
  23. //
  24. //
  25. //***** GetFocusChild(): Get the handle for child that last had focus
  26. // SYNTAX: int GetWindowHandle(int WindowHandle)
  27. //         int GetWindowHandle(string WindowTitle)
  28. // WHERE: WindowHandle: Integer identifier for this window
  29. //        WindowTitle: Partial text title of the window (case-insensitive)
  30. // RETURN: Returns Window handle for a child of this window that now has
  31. //         focus or most recently had focus before this window was
  32. //         made inactive.  NULL if not focus child.
  33. // NOTE: If WindowHandle is input, then this returns WindowHandle if
  34. //       WindowHandle is valid, else returns 0.  WindowTitle is a partial
  35. //       and case-insensitive match and so "write" would match the
  36. //       window titled "Write - THESIS.WRI".
  37. //
  38. //
  39. //***** GetWindowTitle(): Get full Window Title
  40. // SYNTAX: string GetWindowTitle(int WindowHandle)
  41. //         string GetWindowTitle(string WindowTitle)
  42. // WHERE: WindowHandle: Integer identifier for this window
  43. //        WindowTitle: Partial text title of the window (case-insensitive)
  44. // RETURN: Returns Full title for this window, or NULL if window not
  45. //         found or title not found
  46. //
  47. //
  48. //***** SetWindowTitle(): Set title for window
  49. // SYNTAX: bool SetWindowTitle(int WindowHandle,string NewTitle)
  50. //         bool SetWindowTitle(string WindowTitle,string NewTitle)
  51. // WHERE: WindowHandle: Integer identifier for this window
  52. //        WindowTitle: Partial text title of the window (case-insensitive)
  53. //        NewTitle: New full title for this window
  54. // RETURN: TRUE if successful, else FALSE if WindowSpec is invalid.
  55. //
  56. //
  57. //***** IsWindow(): Is this a valid window title or handle
  58. // SYNTAX: bool IsWindow(int WindowHandle)
  59. //         bool IsWindow(string WindowTitle)
  60. // WHERE: WindowHandle: Integer identifier for this window
  61. //        WindowTitle: Partial text title of the window (case-insensitive)
  62. // RETURN: Returns non-zero if this window exists, else returns zero (FALSE)
  63. //
  64. //
  65. //***** IsMinimized(): Is window minimized (Iconic)
  66. // SYNTAX: bool IsMinimized(int WindowHandle)
  67. //         bool IsMinimized(string WindowTitle)
  68. // WHERE: WindowHandle: Integer identifier for this window
  69. //        WindowTitle: Partial text title of the window (case-insensitive)
  70. // RETURN: non-zero if Window is minimized (iconic) else zero (FALSE)
  71. //         if not minimized or if WindowSpec is invalid
  72. //
  73. //
  74. //***** IsMaximized(): Is window maximized
  75. // SYNTAX: bool IsMinimized(int WindowHandle)
  76. //         bool IsMinimized(string WindowTitle)
  77. // WHERE: WindowHandle: Integer identifier for this window
  78. //        WindowTitle: Partial text title of the window (case-insensitive)
  79. // RETURN: non-zero if Window is maximized else zero (FALSE) if not
  80. //         maximized or if WindowSpec is invalid
  81. //
  82. //
  83. //***** IsVisible(): Is window visible
  84. // SYNTAX: bool IsVisible(int WindowHandle)
  85. //         bool IsVisible(string WindowTitle)
  86. // WHERE: WindowHandle: Integer identifier for this window
  87. //        WindowTitle: Partial text title of the window (case-insensitive)
  88. // RETURN: non-zero if Window is visible else zero (FALSE) if not
  89. //         visible or if WindowSpec is invalid. Visible means that
  90. //         the window exists on the screen even if it is covered by
  91. //         other windows
  92. //
  93. //
  94. //***** IsEnabled(): Is window enabled for input
  95. // SYNTAX: bool IsEnabled(int WindowHandle)
  96. //         bool IsEnabled(string WindowTitle)
  97. // WHERE: WindowHandle: Integer identifier for this window
  98. //        WindowTitle: Partial text title of the window (case-insensitive)
  99. // RETURN: non-zero if Window is enabled for mouse and keyboard input,
  100. //         else zero (FALSE) if not enabled or if WindowSpec is invalid
  101. //
  102. //
  103. //***** GetWindowRect(): Get current window coordinates
  104. // SYNTAX: bool GetWindowRect(int WindowHandle,struct Rectangle)
  105. //         bool GetWindowRect(string WindowTitle,struct Rectangle)
  106. // WHERE: WindowHandle: Integer identifier for this window
  107. //        WindowTitle: Partial text title of the window (case-insensitive)
  108. //        Rectangle: receive structure of current window with following members
  109. //             .left - coordinate for left edge of window
  110. //             .right - coordinate for right edge of window
  111. //             .top - coordinate for top edge of window
  112. //             .bottom - coordinate for bottom edge of window
  113. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  114. // MODIFY: Modifies Rectangle structure to current coordinates
  115. //
  116. //
  117. //***** SetWindowRect(): Set current window coordinates
  118. // SYNTAX: bool SetWindowRect(int WindowHandle,struct Rectangle)
  119. //         bool SetWindowRect(string WindowTitle,struct Rectangle)
  120. // WHERE: WindowHandle: Integer identifier for this window
  121. //        WindowTitle: Partial text title of the window (case-insensitive)
  122. //        Rectangle: new structurw of window with the same member elements as
  123. //                   defined above in GetWindowRect()
  124. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  125. //
  126. //
  127. //***** GetScreenSize(): Get width and height of the windows screen
  128. // SYNTAX: void GetScreenSize(int Width,int Height);
  129. // WHERE: Width: receive screen width
  130. //        Height: receive screen height
  131. // MODIFY: Sets Width and Height to dimensions of screen
  132. //
  133. //
  134. //***** GetSize(): Get current width and height of window
  135. // SYNTAX: bool GetSize(int WindowHandle,int Width,int Height)
  136. //         bool GetSize(string WindowTitle,int Width,int Height)
  137. // WHERE: WindowHandle: Integer identifier for this window
  138. //        WindowTitle: Partial text title of the window (case-insensitive)
  139. //        Width: receive current window width
  140. //        Height: receive current window height
  141. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  142. // MODIFY: Sets Width and Height to current dimensions of window
  143. //
  144. //
  145. //***** SetSize(): Get current width and height of window
  146. // SYNTAX: bool GetSize(int WindowHandle,int Width,int Height)
  147. //         bool GetSize(string WindowTitle,int Width,int Height)
  148. // WHERE: WindowHandle: Integer identifier for this window
  149. //        WindowTitle: Partial text title of the window (case-insensitive)
  150. //        Width: new window width
  151. //        Height: new window height
  152. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  153. //
  154. //
  155. //***** GetPosition(): Get current column and row of window
  156. // SYNTAX: bool GetPosition(int WindowHandle,int LeftCol,int BottomRow)
  157. //         bool GetPosition(string WindowTitle,int LeftCol,int BottomRow)
  158. // WHERE: WindowHandle: Integer identifier for this window
  159. //        WindowTitle: Partial text title of the window (case-insensitive)
  160. //        LeftCol: receive current column coordinate of lower-left corner of window
  161. //        Height: receive current row coordinate of lower-left corner of window
  162. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  163. // MODIFY: Sets LeftCol and BottomRow to current lower-left corner coordinates
  164. //
  165. //
  166. //***** SetPosition(): Get current column and row of window
  167. // SYNTAX: bool SetPosition(int WindowHandle,int LeftCol,int BottomRow)
  168. //         bool SetPosition(string WindowTitle,int LeftCol,int BottomRow)
  169. // WHERE: WindowHandle: Integer identifier for this window
  170. //        WindowTitle: Partial text title of the window (case-insensitive)
  171. //        LeftCol: new column coordinate of lower-left corner of window
  172. //        Height: new row coordinate of lower-left corner of window
  173. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  174. //
  175. //
  176. //***** ShowWindow(): Set the way the window is shown (or not shown)
  177. // SYNTAX: bool ShowWindow(int WindowHandle,int ShowCommand)
  178. //         bool ShowWindow(string WindowTitle,int ShowCommand)
  179. // WHERE: WindowHandle: Integer identifier for this window
  180. //        WindowTitle: Partial text title of the window (case-insensitive)
  181. //        ShowCommand: Any of the following values:
  182.       #define SW_HIDE            0  // Hide window; make NOT the active window
  183.       #define SW_MINIMIZE        6  // minimize window; make NOT the active window
  184.       #define SW_RESTORE         9  // activate and display this window; restore from minimized
  185.                                     // or maximized to original size and position before
  186.                                     // it was minimized or maximized
  187.       #define SW_RESTORENOACTIVE (-9) // Same as restore but active window remains active
  188.       #define SW_SHOW            5  // Activate this window in current size and position
  189.       #define SW_SHOWMAXIMIZED   3  // Activate this window and maximize
  190.       #define SW_SHOWMAXNOACTIVE (-3) // Display maximized; active window stays active
  191.       #define SW_SHOWMINIMIZED   2  // Activate this window and display as icon
  192.       #define SW_SHOWMINNOACTIVE 7  // Display as icon; active window stays active
  193.       #define SW_SHOWNA          8  // don't change window state or active window
  194.       #define SW_SHOWNOACTIVATE  4  // display in recent size and place; active window stays active
  195.       #define SW_SHOWNORMAL      1  // same as SW_RESTORE
  196. //
  197. //
  198. //***** GetActiveWindow(): Get the active window
  199. // SYNTAX: int GetActiveWindow()
  200. // RETURN: Return window handle for currently active window
  201. //
  202. //
  203. //***** SetActiveWindow(): Set the currently active window
  204. // SYNTAX: bool SetActiveWindow(int WindowHandle)
  205. //         bool SetActiveWindow(string WindowTitle)
  206. // WHERE: WindowHandle: Integer identifier for this window
  207. //        WindowTitle: Partial text title of the window (case-insensitive)
  208. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  209. //
  210. //
  211. //***** CloseWindow(): Send a CLOSE message to this window
  212. // SYNTAX: bool CloseWindow(int WindowHandle)
  213. //         bool CloseWindow(string WindowTitle)
  214. // WHERE: WindowHandle: Integer identifier for this window
  215. //        WindowTitle: Partial text title of the window (case-insensitive)
  216. // RETURN: TRUE if WindowSpec is valid, else FALSE.
  217. //
  218. //
  219. //***** GetFocusChild(): Get the handle for child that last had focus
  220. // SYNTAX: int GetFocusChild(int WindowHandle)
  221. //         int GetFocusChild(string WindowTitle)
  222. // WHERE: WindowHandle: Integer identifier for this window
  223. //        WindowTitle: Partial text title of the window (case-insensitive)
  224. // RETURN: Returns Window handle for a child of this window that now has
  225. //         focus or most recently had focus before this window was
  226. //         made inactive.  NULL if not focus child.
  227. //
  228. //
  229. //
  230. //
  231. // Initialization: make sure that PMdll.lib has been #included
  232. if !defined(_PMDLL_LIB) {
  233.    printf("\n\aMust #include \"PMdll.lib\" before #include \"WinTools.lib\"\n");
  234.    abort();
  235. }
  236. #define _WINDTOOLS_LIB  1
  237.  
  238. #define HWND_DESKTOP 1
  239.  
  240. /*******************************************************************
  241.  *********        END OF DESCRIPTION FOR WINSET.LIB        *********
  242.  *******************************************************************/
  243.  
  244.  
  245. GetWindowHandle(WindowSpec)
  246. {
  247.    // Test if input is string (WindowTitle) or integer (WindowHandle)
  248.    if ( 0 == DataDimension(WindowSpec) ) {
  249.  
  250.       // Input is WindowHandle.  Verify that this handle is valid
  251.       #define ORD_WIN32ISWINDOW  772
  252.       if ( HWND_DESKTOP == WindowSpec
  253.         || PMDynamicLink("PMWIN",ORD_WIN32ISWINDOW,BIT32,CDECL,PMInfo().hab,WindowSpec) )
  254.          return(WindowSpec);
  255.  
  256.    } else {
  257.  
  258.       // Input is WindowTitle, build list of titles and look for this one
  259.       _TitleLen = strlen(WindowSpec);
  260.  
  261.       // Build list of all root window titles
  262.       if ( NULL != (_SwitchList = WinQuerySwitchList(PMInfo().hab)) ) {
  263.          // for each window, compare its title against Window
  264.          BLObSize(_buf,200);
  265.          for ( _i = GetArraySpan(_SwitchList); 0 <= _i; _i-- ) {
  266.             if ( 0 == WinQuerySwitchEntry(_SwitchList[_i],_SwEntry) ) {
  267.                if ( NULL != (_title = GetWindowTitle(_SwEntry.hwnd))
  268.                  && !memicmp(WindowSpec,_title,_TitleLen) )
  269.                   return(_SwEntry.hwnd);
  270.             }
  271.          }
  272.       }
  273.    }
  274.    // if didn't return a handle above, then title was not found
  275.    return(0);
  276. }
  277.  
  278.  
  279. GetWindowTitle(WindowSpec)
  280. {
  281.    if ( (_handle = GetWindowHandle(WindowSpec)) ) {
  282.       #define ORD_WIN32QUERYWINDOWTEXT 841
  283.       BLObSize(_buf,200);
  284.       if ( PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWTEXT,BIT32,CDECL,_handle,199,_buf) ) {
  285.          strcpy(_ret,_buf);
  286.          return(_ret);
  287.       }
  288.    }
  289.    return(NULL);
  290. }
  291.  
  292. SetWindowTitle(WindowSpec,NewTitle)
  293. {
  294.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  295.       return(FALSE);
  296.    #define ORD_WIN32SETWINDOWTEXT   877
  297.    PMDynamicLink("PMWIN",ORD_WIN32SETWINDOWTEXT,BIT32,CDECL,_handle,NewTitle);
  298.    return(TRUE);
  299. }
  300.  
  301.  
  302. IsWindow(WindowSpec)
  303. {
  304.    return( GetWindowHandle(WindowSpec) );
  305. }
  306.  
  307.  
  308. #define SWP_SIZE              0x0001
  309. #define SWP_MOVE              0x0002
  310. #define SWP_ZORDER            0x0004
  311. #define SWP_SHOW              0x0008
  312. #define SWP_HIDE              0x0010
  313. #define SWP_NOREDRAW          0x0020
  314. #define SWP_NOADJUST          0x0040
  315. #define SWP_ACTIVATE          0x0080
  316. #define SWP_DEACTIVATE        0x0100
  317. #define SWP_EXTSTATECHANGE    0x0200
  318. #define SWP_MINIMIZE          0x0400
  319. #define SWP_MAXIMIZE          0x0800
  320. #define SWP_RESTORE           0x1000
  321. #define SWP_FOCUSACTIVATE     0x2000
  322. #define SWP_FOCUSDEACTIVATE   0x4000
  323.  
  324. QueryWinFlags(WindowSpec)  // return WinPos flags for this window
  325. {                          // return 0 if no good
  326.    if ( (_handle = GetWindowHandle(WindowSpec)) ) {
  327.       #define SWP_BLOB_SIZE 9 * 4
  328.       BLObSize(_swp,SWP_BLOB_SIZE);
  329.       #define ORD_WIN32QUERYWINDOWPOS  837
  330.       if ( PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWPOS,BIT32,CDECL,_handle,_swp) )
  331.          return(BLObGet(_swp,0,UWORD32));
  332.    }
  333.    return(0);
  334. }
  335.  
  336. IsMinimized(WindowSpec)
  337. {
  338.    return( QueryWinFlags(WindowSpec) & SWP_MINIMIZE );
  339. }
  340.  
  341.  
  342. IsMaximized(WindowSpec)
  343. {
  344.    return( QueryWinFlags(WindowSpec) & SWP_MAXIMIZE );
  345. }
  346.  
  347.  
  348.  
  349. IsVisible(WindowSpec)
  350. {
  351.    #define ORD_WIN32ISWINDOWVISIBLE 775
  352.    return( (_handle = GetWindowHandle(WindowSpec))
  353.          ? PMDynamicLink("PMWIN",ORD_WIN32ISWINDOWVISIBLE,BIT32,CDECL,_handle)
  354.          : FALSE );
  355. }
  356.  
  357.  
  358. IsEnabled(WindowSpec)
  359. {
  360.    #define ORD_WIN32ISWINDOWENABLED 773
  361.    return( (_handle = GetWindowHandle(WindowSpec))
  362.          ? PMDynamicLink("PMWIN",ORD_WIN32ISWINDOWENABLED,BIT32,CDECL,_handle)
  363.          : FALSE );
  364. }
  365.  
  366.  
  367. SetWindowPos(Handle,BehindHandle,Column,Row,Width,Height,Flags)
  368. {
  369.    #define ORD_WIN32SETWINDOWPOS 875
  370.    PMDynamicLink("PMWIN",ORD_WIN32SETWINDOWPOS,BIT32,CDECL,
  371.                  Handle,BehindHandle,Column,Row,Width,Height,Flags);
  372. }
  373.  
  374.  
  375. GetWindowRect(WindowSpec,Rectangle)
  376. {
  377.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  378.       return(FALSE);
  379.    #define SWP_BLOB_SIZE 9 * 4
  380.    BLObSize(_swp,SWP_BLOB_SIZE);
  381.    #define ORD_WIN32QUERYWINDOWPOS  837
  382.    if ( !DynamicLink("PMWIN",ORD_WIN32QUERYWINDOWPOS,BIT32,CDECL,_handle,_swp) )
  383.       return(FALSE);
  384.    _height = BLObGet(_swp,4,SWORD32);
  385.    _width = BLObGet(_swp,8,SWORD32);
  386.    Rectangle.bottom = BLObGet(_swp,12,SWORD32);
  387.    Rectangle.left = BLObGet(_swp,16,SWORD32);
  388.    Rectangle.top = Rectangle.bottom + _height - 1;
  389.    Rectangle.right = Rectangle.left + _width - 1;
  390.    return(TRUE);
  391. }
  392.  
  393.  
  394. SetWindowRect(WindowSpec,Rectangle)
  395. {
  396.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  397.       return(FALSE);
  398.    SetWindowPos(_handle,0,Rectangle.left,Rectangle.bottom,
  399.                 Rectangle.right - Rectangle.left + 1,
  400.                 Rectangle.top - Rectangle.bottom + 1,
  401.                 SWP_SIZE | SWP_MOVE | SWP_NOADJUST);
  402.    return(TRUE);
  403. }
  404.  
  405.  
  406. GetScreenSize(Width,Height)
  407. {
  408.    GetSize(HWND_DESKTOP,Width,Height);
  409. }
  410.  
  411.  
  412. GetSize(WindowSpec,Width,Height)
  413. {
  414.    if ( !GetWindowRect(WindowSpec,_rect) )
  415.       return(FALSE);
  416.    Width = _rect.right - _rect.left + 1;
  417.    Height = _rect.top - _rect.bottom + 1;
  418.    return(TRUE);
  419. }
  420.  
  421.  
  422. SetSize(WindowSpec,Width,Height)
  423. {
  424.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  425.       return(FALSE);
  426.    SetWindowPos(_handle,0,0,0,Width,Height,SWP_SIZE);
  427.    return(TRUE);
  428. }
  429.  
  430.  
  431. GetPosition(WindowSpec,LeftCol,BottomRow)
  432. {
  433.    if ( !GetWindowRect(WindowSpec,_rect) )
  434.       return(FALSE);
  435.    LeftCol = _rect.left;
  436.    BottomRow = _rect.bottom;
  437.    return(TRUE);
  438. }
  439.  
  440.  
  441. SetPosition(WindowSpec,LeftCol,BottomRow)
  442. {
  443.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  444.       return(FALSE);
  445.    SetWindowPos(_handle,0,LeftCol,BottomRow,0,0,SWP_MOVE | SWP_NOADJUST);
  446.    return(TRUE);
  447. }
  448.  
  449.  
  450. ShowWindow(WindowSpec,CmdShow)
  451. {
  452.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  453.       return(FALSE);
  454.    _active = 0;
  455.    switch( CmdShow ) {
  456.       case SW_HIDE:
  457.          SetWindowPos(_handle,0,0,0,0,0,SWP_HIDE);
  458.          break;
  459.       case SW_SHOWNOACTIVATE:
  460.          _active = GetActiveWindow();
  461.          SetWindowPos(_handle,0,0,0,0,0,SWP_SHOW);
  462.          break;
  463.       case SW_MINIMIZE:
  464.       case SW_SHOWMINNOACTIVE:
  465.          SetWindowPos(_handle,0,0,0,0,0,SWP_MINIMIZE);
  466.          break;
  467.       case SW_SHOWMINIMIZED:
  468.          SetWindowPos(_handle,0,0,0,0,0,SWP_MINIMIZE | SWP_ACTIVATE);
  469.          break;
  470.       case SW_SHOWMAXNOACTIVE:
  471.          SetWindowPos(_handle,0,0,0,0,0,SWP_MAXIMIZE);
  472.          break;
  473.       case SW_SHOWMAXIMIZED:
  474.          SetWindowPos(_handle,0,0,0,0,0,SWP_MAXIMIZE | SWP_ACTIVATE);
  475.          break;
  476.       case SW_RESTORENOACTIVE:
  477.          SetWindowPos(_handle,0,0,0,0,0,SWP_RESTORE);
  478.          break;
  479.       case SW_RESTORE:
  480.       case SW_SHOWNORMAL:
  481.          SetWindowPos(_handle,0,0,0,0,0,SWP_RESTORE | SWP_ACTIVATE);
  482.          break;
  483.       case SW_SHOW:
  484.          SetActiveWindow(_handle);
  485.          break;
  486.       case SW_SHOWNA:
  487.          break;
  488.       default: return(FALSE);
  489.    }
  490.    if ( _active )
  491.       SetActiveWindow(_active);
  492.    return(TRUE);
  493. }
  494.  
  495.  
  496. GetActiveWindow()
  497. {
  498.    #define ORD_WIN32QUERYACTIVEWINDOW  799
  499.    return PMDynamicLink("PMWIN",ORD_WIN32QUERYACTIVEWINDOW,BIT32,CDECL,HWND_DESKTOP);
  500. }
  501.  
  502.  
  503. SetActiveWindow(WindowSpec)
  504. {
  505.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  506.       return(FALSE);
  507.    SetWindowPos(_handle,0,0,0,0,0,SWP_ACTIVATE);
  508.    return(TRUE);
  509. }
  510.  
  511. CloseWindow(WindowSpec)
  512. {
  513.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  514.       return(FALSE);
  515.    #define WM_CLOSE  0x0029
  516.    PostMessage(_handle,WM_CLOSE,0,0);
  517.    return(TRUE);
  518. }
  519.  
  520. GetFocusChild(WindowSpec)
  521. {
  522.    if ( !(_handle = GetWindowHandle(WindowSpec)) )
  523.       return(FALSE);
  524.    if ( _handle == GetActiveWindow() ) {
  525.       // This is currently the active window, so just get the focus window
  526.       #define ORD_WIN32QUERYFOCUS   817
  527.       return PMDynamicLink("PMWIN",ORD_WIN32QUERYFOCUS,BIT32,CDECL,HWND_DESKTOP);
  528.    } else {
  529.       // This window is not currently active, so get what the active window
  530.       // used to be.
  531.       #define QWL_HWNDFOCUSSAVE           0x0018
  532.       #define ORD_WIN32QUERYWINDOWULONG   843
  533.       return PMDynamicLink("PMWIN",ORD_WIN32QUERYWINDOWULONG,BIT32,CDECL,
  534.                            _handle,QWL_HWNDFOCUSSAVE);
  535.    }
  536. }
  537.  
  538.